<?php
// +----------------------------------------------------------------------
// | 幕小铺
// +----------------------------------------------------------------------
// | 版权所有 2016~2020 幕小铺科技（大连）有限公司
// +----------------------------------------------------------------------
// | 2020/03/14
// +----------------------------------------------------------------------

namespace app\user_center\admin;

use app\admin\controller\Admin;
use app\common\builder\ZBuilder;

/**
 * 意见反馈 控制器
 * @package app\user\admin
 */
class Feedback extends Admin
{
	
    /**
     * 用户首页
     * @author jason wang <120907037@qq.com>
     * @return mixed
     * @throws \think\Exception
     * @throws \think\exception\DbException
     */
    public function index()
    {
        cookie('__forward__', $_SERVER['REQUEST_URI']);

        // 获取排序
        $order = $this->getOrder();
        // 获取筛选
        $map = $this->getMap();

        // 数据列表
        $data_list = model('UcMemberFeedback', 'model\user')->where($map)->order($order)->paginate();

        foreach ($data_list as $key => $value) {
            $data_list[$key]['nick_name'] = $value['get_member']['nick_name'];
        }
		
        // 使用ZBuilder快速创建数据表格
        return ZBuilder::make('table')
            ->setPageTitle('意见反馈') // 设置页面标题
            ->setPrimaryKey('uid') // 设置主键名为username
            ->setTableName('uc_member_feedback') // 设置数据表名
            //->setSearch(['id' => 'ID', 'username' => '用户名', 'email' => '邮箱']) // 设置搜索参数
            ->addColumns([ // 批量添加列
                ['__INDEX__', '序号'],
				['nick_name', '昵称', 'link', url('user_center/index/details', ['uid' => '__uid__']), '_blank', 'pop'],
                ['content', '详情'],
                ['create_time', '反馈时间', 'datetime'],
                ['right_button', '操作', 'btn']
            ])
            ->addTimeFilter('create_time', '', ['开始时间', '结束时间'])
            ->addOrder('create_time') // 添加排序
            ->addRightButton('delete') // 批量添加右侧按钮
            ->setRowList($data_list) // 设置表格数据
            ->fetch(); // 渲染页面
    }
}
